//默认自动获取本地用户登录缓存
export default {
  state: {
    axiosSign: {},
    token: "",
    userId: "",
    userType: ""
  },
  mutations: {
    setAxiosSign(state, obj) {
      state.axiosSign[obj.key] = obj.value;
    },
    setUserSign(state) {
      let info = {};
      if (window.localStorage.userInfo) {
        info = JSON.parse(window.localStorage.userInfo);
      } else if (window.sessionStorage.userInfo) {
        info = JSON.parse(window.sessionStorage.userInfo);
      }
      state.token = info.token;
      state.userId = info.userId;
      state.userType = info.userType
    },
    removeUserSign(state) {
      window.localStorage.removeItem("userInfo");
      window.sessionStorage.removeItem("userInfo");
      state.token = "";
      state.userId = "";
      state.userType = "";
    }
  }
};
